package com.h819.core.net.ftp.ftp4j;

import it.sauronsoftware.ftp4j.FTPDataTransferListener;
import org.apache.log4j.Logger;

import java.io.File;

/**
 * @Title: Ftp4jTransferListener.java
 * @Description: TODO(ftp4j 传输监听器)
 * @author H819
 * @date 2010-3-19
 * @version V1.0
 */
public class Ftp4jTransferListener implements FTPDataTransferListener {

	private Logger log = Logger.getLogger(Ftp4jTransferListener.class);
	private String fileName = "";

	public Ftp4jTransferListener() {

	}

	public Ftp4jTransferListener(File file) {
		fileName = file.getName();
	}

	public void started() {
		// Transfer started
		// 文件开始上传或下载时触发
		log.info("Transfer started... : " + fileName);
	}

	public void transferred(int length) {
		// Yet other length bytes has been transferred since the last time this
		// method was called
		// 显示已经传输的字节数，会不停的刷新显示，所以暂时关闭
		// log.info("Transferd " + length + " ...");

	}

	public void completed() {
		// Transfer completed
		// 文件传输完成时，触发
		log.info("Transfer completed... : " + fileName);
	}

	public void aborted() {
		// Transfer aborted
		// 传输放弃时触发
		log.info("Transfer aborted... : " + fileName);
	}

	public void failed() {
		// Transfer failed
		// 传输失败时触发
		log.info("Transfer failed... : " + fileName);
	}

}
